package com.example.fresh_fruit.service.Impl;

import com.example.fresh_fruit.entity.Purchase;
import com.example.fresh_fruit.entity.PutHouseing;
import com.example.fresh_fruit.mapper.PurchaseMapper;
import com.example.fresh_fruit.mapper.PutHouseingMapper;
import com.example.fresh_fruit.service.PutHouseingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :飞天の鱼
 * @date : 2022/8/25 15:35
 */
@Service
public class PutHouseingServiceImpl implements PutHouseingService {

    @Autowired
    private PutHouseingMapper putHouseingMapper;

    @Autowired
    private PurchaseMapper purchaseMapper;

    @Override
    public List<PutHouseing> selectAll() {
        return putHouseingMapper.selectAll();
    }

    @Override
    public int insertPutHouseing(PutHouseing putHouseing) {
        int insertPutHouseing = putHouseingMapper.insertPutHouseing(putHouseing);
        return insertPutHouseing;
    }

    @Override
    public Purchase findByPurchaseId(Integer id) {
        Purchase purchase = purchaseMapper.selectById(id);
        return purchase;
    }

    @Override
    public int updataPutHouseingState(Integer id) {
        int state = putHouseingMapper.updataPutHouseingState(id);
        return state;
    }

    @Override
    public int findById(Integer id) {
        int houseingMapperById = putHouseingMapper.findById(id);
        if (houseingMapperById!=1){
            return 1;
        }
        return 0;
    }

}
